/**
 * 
 */
package com.ydy.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ydy.annotation.AdminToken;
import com.ydy.service.requestLog.RequestLogService;
import com.ydy.vo.RequestLogCountVo;

/**
 * @author xuzhaojie
 *
 *         2019年8月6日 上午9:17:29
 */
@Controller
@RequestMapping(value = "requestLog", name = "请求日志统计模块")
public class RequestLogController {

	@Autowired
	private RequestLogService requestLogService;

	@AdminToken
	@GetMapping(value = "selectCountByDay", name = "查找时间段内每天访问量")
	@ResponseBody
	public ResponseEntity<List<RequestLogCountVo>> selectCountByDay(Date startTime, Date endTime) {
		List<RequestLogCountVo> list = requestLogService.selectCountByDay(startTime, endTime);
		return ResponseEntity.ok(list);
	}

	@AdminToken
	@GetMapping(value = "selectIpCountByDay", name = "查询时间段内IP每天访问量")
	@ResponseBody
	public ResponseEntity<List<RequestLogCountVo>> selectIpCountByDay(Date startTime, Date endTime) {
		List<RequestLogCountVo> list = requestLogService.selectIpCountByDay(startTime, endTime);
		return ResponseEntity.ok(list);
	}

	@AdminToken
	@GetMapping(value = "selectCountByHour", name = "查找某天时间段访问量")
	@ResponseBody
	public ResponseEntity<List<RequestLogCountVo>> selectCountByHour(Date date) {
		List<RequestLogCountVo> list = requestLogService.selectCountByHour(date);
		return ResponseEntity.ok(list);
	}
}